package com.meishij.fragment.malldetailfragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.meishij.R;
import com.meishij.adapter.MallItemConsultAdapter;
import com.meishij.entry.MallSellEntry;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class MallMessageConsultFragment extends Fragment {


    private View view;
    private RecyclerView mall_sell_consult;
    private List<Object> objectList=new ArrayList<>();
    private List<String> stringList=new ArrayList<>();
    private MallItemConsultAdapter mallItemConsultAdapter;

    public MallMessageConsultFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        if(view!=null){
            return view;
        }
        view = inflater.inflate(R.layout.fragment_mall_message_consult, container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        MallSellEntry.ObjBean data = (MallSellEntry.ObjBean) bundle.getSerializable("data");
        List<MallSellEntry.ObjBean.QaListBean> qa_list = data.getQa_list();
        mall_sell_consult = ((RecyclerView) view.findViewById(R.id.mall_sell_consult));
        GridLayoutManager layoutManager = (GridLayoutManager) mall_sell_consult.getLayoutManager();
        layoutManager.setSpanCount(1);
        String logo = data.getStore_infomation().getLogo();
        stringList.add(logo);
        objectList.add(0,qa_list);
        objectList.add(1,null);
        objectList.add(2,stringList);//加载logo
        objectList.add(3,null);//加载"了解商家详情"
        mallItemConsultAdapter = new MallItemConsultAdapter(getContext(),objectList,new int[]{
                R.layout.layout_mall_zc,
                R.layout.layout_mall_sell_item_shaidan_more,
                R.layout.layout_mall_item_bottom_loge,
                R.layout.layout_mall_detail_item_bottom_text
        });
        mall_sell_consult.setAdapter(mallItemConsultAdapter);
    }
}
